package com.design.design.pattern.singleton;

public class Test {
    public static void main(String[] args) throws IllegalAccessException, InstantiationException {

        Apple instance1 = Apple.getInstance();
        instance1.setOrigin("China");
        Apple instance2 = Apple.getInstance();
        instance2.setOrigin("USA");
        System.out.println("instance1 addr: " + instance1);
        System.out.println("instance2 addr: " + instance2);
        System.out.println(instance1 == instance2);
        System.out.println(instance1.getOrigin());
        System.out.println(instance2.getOrigin());

        System.out.println("==========================================");

        Pear pear1 = new Pear();
        pear1.setOrigin("Asia");
        Pear pear2 = new Pear();
        pear2.setOrigin("Europe");
        System.out.println("pear1 addr: " + pear1);
        System.out.println("pear2 addr: " + pear2);
        System.out.println(pear1 == pear2);
        System.out.println(pear1.getOrigin());
        System.out.println(pear2.getOrigin());

        System.out.println("==========================================");
        EnumInstance.INSTANCE.setData(new Orange());
        Orange orange1 = (Orange)EnumInstance.INSTANCE.getData();
        Orange orange2 = (Orange)EnumInstance.INSTANCE.getData();
        System.out.println("orange1 addr: " + orange1);
        System.out.println("orange2 addr: " + orange2);
        System.out.println(orange1 == orange2);

    }
}
